import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BannerVO, BannerForm, BannerQuery } from '@/api/market/banner/types';

/**
 * 查询轮播管理列表
 * @param query
 * @returns {*}
 */

export const listBanner = (query?: BannerQuery): AxiosPromise<BannerVO[]> => {
  return request({
    url: '/market/banner/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询轮播管理详细
 * @param id
 */
export const getBanner = (id: string | number): AxiosPromise<BannerVO> => {
  return request({
    url: '/market/banner/' + id,
    method: 'get'
  });
};

/**
 * 新增轮播管理
 * @param data
 */
export const addBanner = (data: BannerForm) => {
  return request({
    url: '/market/banner',
    method: 'post',
    data: data
  });
};

/**
 * 修改轮播管理
 * @param data
 */
export const updateBanner = (data: BannerForm) => {
  return request({
    url: '/market/banner',
    method: 'put',
    data: data
  });
};

/**
 * 删除轮播管理
 * @param id
 */
export const delBanner = (id: string | number | Array<string | number>) => {
  return request({
    url: '/market/banner/' + id,
    method: 'delete'
  });
};
